import request from '../utils/request';

export default {
    //  获取所有部门
    getAllDepart() {
        return request({
            url: `/department/findAll`,
            method: 'get',
        });
    },
    searchTarget(yearTargetId, type, deptId, level, isAssess) {
        return request({
            url: `/statistics/dept/findByCondition`,
            method: 'get',
            params: {
                yearTargetId, type, deptId, level, isAssess
            }
        })
    },
    getDepartmentById(deptId){
        return request({
            url: `/department/findById`,
            method: 'get',
            params: {
                deptId
            }
        })
    },
    exceptSelf(acceptDeptId){
        return request({
            url: `/target/subSelfDepartment`,
            method: 'get',
            params: {
                acceptDeptId
            }
        })
    },
    // 根据名称查询
    getByName(name){
        return request({
            url: `/department/findByName`,
            method: 'get',
            params: {
                name
            }
        });
    },
    getDepartmentByPage(pageNum,pageSize){
        var param ={
            pageNum: pageNum,
            pageSize: pageSize
        }
        return request({
            url: `/department/selectPage`,
            method: 'post',
            data: param
        });
    },
    //新增
    addDepartment(department){
        return request({
            url: `/department/add`,
            method: 'post',
            data: department
        });
    },
    editDepartment(id,department){
        return request({
            url: `/department/update/${id}`,
            method: 'put',
            data: department
        });
    },
    deleteDepartment(id){
        return request({
            url: `/department/delete`,
            method: 'delete',
            params: {
                id
            }
        });
    }
}
